﻿using Code.Services.Menus;
using Code.Services.Menus.Dto;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using CodeAPP.Auth;

namespace CodeAPP.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    [CustomAuthorize]
    public class MenuController : ControllerBase
    {
        private readonly IMenuService service;

        public MenuController(IMenuService service)
        {
            this.service = service;
        }

        [HttpGet]
        public IActionResult GetTreeData()
        {
            return new JsonResult(service.GetTreeData());
        }

        [HttpPost("/menu/create")]
        public IActionResult CreateMenu(MenuDto dto)
        {
            return Ok(service.CreateMenu(dto));
        }
    }
}
